import uiautomation
import time

# 查找窗口中的程序;
window = uiautomation.WindowControl(ClassName='MstarAWDDIRECTClass', Name='Morningstar Direct', Depth=1)
# window = uiautomation.WindowControl(ClassName='#32770', Name='Morningstar Direct', Depth=1)
print(window)
# 获取本地窗口句柄：
handle = window.NativeWindowHandle
print(handle)
window.Maximize()
window.MoveWindow(0, 0, 1366, 728)
print(window)
exit()
# 隐藏窗口
window.Hide(0)
# 显示窗口
time.sleep(2)
window.Show(0)
# 激活窗口;
window.SetActive()

# 窗口置顶
window.SetTopmost(isTopmost=False)

# 窗口居中
window.MoveToCenter()

# 关闭窗口；
window.GetWindowPattern().Close()
exit()
# 窗口最大化；
window.Maximize()
time.sleep(2)
# 窗口最小化
window.Minimize()
# 截图；
window.CaptureToImage('win.png')
# 切换为当前窗口
window.SwitchToThisWindow()
